from  time import*
file = open("m1_sorted.txt").readlines()
mas=list()
for j in range(len(file)):
    mas.append(int(file[j]))
N = len(mas)
a = time()
for i in range(N-1):
    z = 0
    for y in range(N-i-1):
        if mas[y]>mas[y+1]:
            mas[y],mas[y+1]= mas[y+1],mas[y]
            z+=1
    if z == 0:
        break
d = time()
s=d-a
s*=1000
print("m1_sorted",mas,"milliseconds", int(round(s)))
file2 = open("m2_reverse.txt").readlines()
f=list()
for j in range(len(file2)):
    f.append(int(file2[j]))
Q = len(mas)
q = time()
for i in range(N-1):
    w= 0
    for y in range(N-i-1):
        if f[y]>f[y+1]:
            f[y],f[y+1]= f[y+1],f[y]
            w+=1
    if w == 0:
        break
m = time()
v=m-q
v*=1000
print("m2_reverse",f,"milliseconds",int(round(v)))
file3 = open("m3_shuffle.txt").readlines()
l=list()
for j in range(len(file3)):
    l.append(int(file3[j]))
L = len(mas)
U = time()
for i in range(N-1):
    C= 0
    for y in range(N-i-1):
        if l[y]>l[y+1]:
            l[y],l[y+1]= l[y+1],l[y]
            C+=1
    if C == 0:
        break
I = time()
X=I-U
X*=1000
print("m3_shuffle",l,"milliseconds",int(round(X)))
